# coding: utf-8
from typing import List, Dict, Any

from PySide6.QtWidgets import QHBoxLayout, QVBoxLayout, QWidget
from qfluentwidgets import BodyLabel, setFont

from components import TextBrowser
from .song_info_card import RecommendedSongCard


class LyricCardWidget(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.horizontalLayout = QHBoxLayout(self)
        self.verticalLayout = QVBoxLayout()
        self.songNameLabel = BodyLabel('歌名', self)
        self.lyricTextBrowser = TextBrowser(self)
        self.recommendSongCard = RecommendedSongCard(self)

        self.__initWidgets()

    def __initWidgets(self):
        setFont(self.songNameLabel, 39)
        self.verticalLayout.setSpacing(29)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.addWidget(self.songNameLabel)
        self.verticalLayout.addWidget(self.lyricTextBrowser)
        self.horizontalLayout.addLayout(self.verticalLayout)
        self.horizontalLayout.addWidget(self.recommendSongCard)

    def setLyric(self, lyric: str):
        self.lyricTextBrowser.setText(lyric)

    def setSongInfo(self, title: str, songInfo: List[Dict[str, Any]]):
        self.recommendSongCard.addCard(title, songInfo)
